package com.ruoyi.module.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.module.domain.DictLanguageCategory;
import com.ruoyi.module.service.IDictLanguageCategoryService;

/**
 * 语言分类Controller
 * 
 * @author ruoyi
 */
@RestController
@RequestMapping("/module/dict/language")
public class DictLanguageCategoryController extends BaseController
{
    @Autowired
    private IDictLanguageCategoryService dictLanguageCategoryService;

    /**
     * 查询语言分类列表
     */
    @PreAuthorize("@ss.hasPermi('module:dict:language:list')")
    @GetMapping("/list")
    public TableDataInfo list(DictLanguageCategory dictLanguageCategory)
    {
        startPage();
        List<DictLanguageCategory> list = dictLanguageCategoryService.selectDictLanguageCategoryList(dictLanguageCategory);
        return getDataTable(list);
    }

    /**
     * 查询所有语言分类
     */
    @GetMapping("/all")
    public AjaxResult all()
    {
        List<DictLanguageCategory> list = dictLanguageCategoryService.selectDictLanguageCategoryAll();
        return success(list);
    }

    /**
     * 根据ID查询语言分类详情
     */
    @PreAuthorize("@ss.hasPermi('module:dict:language:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(dictLanguageCategoryService.selectDictLanguageCategoryById(id));
    }

    /**
     * 新增语言分类
     */
    @PreAuthorize("@ss.hasPermi('module:dict:language:add')")
    @Log(title = "语言分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DictLanguageCategory dictLanguageCategory)
    {
        dictLanguageCategory.setCreateBy(getUsername());
        return toAjax(dictLanguageCategoryService.insertDictLanguageCategory(dictLanguageCategory));
    }

    /**
     * 修改语言分类
     */
    @PreAuthorize("@ss.hasPermi('module:dict:language:edit')")
    @Log(title = "语言分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DictLanguageCategory dictLanguageCategory)
    {
        dictLanguageCategory.setUpdateBy(getUsername());
        return toAjax(dictLanguageCategoryService.updateDictLanguageCategory(dictLanguageCategory));
    }

    /**
     * 删除语言分类
     */
    @PreAuthorize("@ss.hasPermi('module:dict:language:remove')")
    @Log(title = "语言分类", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(dictLanguageCategoryService.deleteDictLanguageCategoryByIds(ids));
    }
}

